package io.renren.modules.noc.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import io.renren.modules.noc.entity.NocBusinessLabelEntity;
import io.renren.modules.noc.service.NocBusinessLabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 展商标签表
 *
 * @author whc
 * @email hucheng_86@126.com
 * @date 2019-07-15 15:51:08
 */
@RestController
@RequestMapping("noc/nocbusinesslabel")
public class NocBusinessLabelController {
    @Autowired
    private NocBusinessLabelService nocBusinessLabelService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("noc:nocbusinesslabel:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = nocBusinessLabelService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("noc:nocbusinesslabel:info")
    public R info(@PathVariable("id") Integer id){
        NocBusinessLabelEntity nocBusinessLabel = nocBusinessLabelService.getById(id);

        return R.ok().put("nocBusinessLabel", nocBusinessLabel);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("noc:nocbusinesslabel:save")
    public R save(@RequestBody NocBusinessLabelEntity nocBusinessLabel){
        nocBusinessLabelService.save(nocBusinessLabel);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("noc:nocbusinesslabel:update")
    public R update(@RequestBody NocBusinessLabelEntity nocBusinessLabel){
        ValidatorUtils.validateEntity(nocBusinessLabel);
        nocBusinessLabelService.updateById(nocBusinessLabel);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("noc:nocbusinesslabel:delete")
    public R delete(@RequestBody Integer[] ids){
        nocBusinessLabelService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
